﻿' This software is licensed under Microsoft Public License (Ms-PL), which governs use of the accompanying software. 
' If you use the software, you accept this license. 

' The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, 
' guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot 
' change. To the extent permitted under your local laws, the contributors exclude the implied warranties of 
' merchantability, fitness for a particular purpose and non-infringement.

Imports System.ServiceModel
Imports System.ServiceModel.Description
Imports System.ServiceModel.Channels
Imports System.ServiceModel.Dispatcher

Namespace Description
    ''' <summary>
    ''' Implements the standard REST behavior for the <see cref="Rest.RestClient">RestClient</see> class.
    ''' </summary>
    ''' <remarks></remarks>
    Friend NotInheritable Class RestClientBehavior
        Implements IEndpointBehavior

#Region "Constructor"
        ''' <summary>
        ''' Returns a new instance of the RestErrorInspectorBehavior class.
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
        End Sub
#End Region

#Region "IEndpointBehavior Implementation"
        ''' <summary>
        ''' Adds binding parameters to the endpoint.
        ''' </summary>
        ''' <param name="endpoint">Endpoint to apply parameters to.</param>
        ''' <param name="bindingParameters">Binding parameters of the current binding.</param>
        ''' <remarks></remarks>
        Public Sub AddBindingParameters(endpoint As System.ServiceModel.Description.ServiceEndpoint, bindingParameters As Channels.BindingParameterCollection) Implements System.ServiceModel.Description.IEndpointBehavior.AddBindingParameters

        End Sub

        ''' <summary>
        ''' Installs the client behaviors for REST handling.
        ''' </summary>
        ''' <param name="endpoint">Endpoint to apply behavior to.</param>
        ''' <param name="clientRuntime">Runtime of the client framework.</param>
        ''' <remarks></remarks>
        Public Sub ApplyClientBehavior(endpoint As System.ServiceModel.Description.ServiceEndpoint, clientRuntime As System.ServiceModel.Dispatcher.ClientRuntime) Implements System.ServiceModel.Description.IEndpointBehavior.ApplyClientBehavior
            ' install the error inspector
            clientRuntime.MessageInspectors.Add(New RestErrorInspector())
            clientRuntime.MessageInspectors.Add(New RestCookieInspector())
        End Sub

        ''' <summary>
        ''' Not used.
        ''' </summary>
        ''' <param name="endpoint"></param>
        ''' <param name="endpointDispatcher"></param>
        ''' <remarks></remarks>
        Public Sub ApplyDispatchBehavior(endpoint As System.ServiceModel.Description.ServiceEndpoint, endpointDispatcher As System.ServiceModel.Dispatcher.EndpointDispatcher) Implements System.ServiceModel.Description.IEndpointBehavior.ApplyDispatchBehavior

        End Sub

        ''' <summary>
        ''' Not used.
        ''' </summary>
        ''' <param name="endpoint"></param>
        ''' <remarks></remarks>
        Public Sub Validate(endpoint As System.ServiceModel.Description.ServiceEndpoint) Implements System.ServiceModel.Description.IEndpointBehavior.Validate

        End Sub
#End Region
    End Class
End Namespace
